package com.levi.functionalinterface;

import com.levi.lambda.Student;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @author shentong
 * @date 2022/1/10 10:39 PM
 * @description  方法引用，代码编写更加简洁
 */
public class MyMethodReference {

    public static void main(String[] args) {
        List<Student> studentList = new ArrayList<Student>(){{
            add(new Student(2, "张三", "男"));
            add(new Student(1, "李四", "男"));
            add(new Student(3, "王五", "女"));
        }};
        studentList.sort(Comparator.comparing(Student::getId));
        studentList.forEach(System.out::println);
    }
}
